<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var s = 'dat2017';
//    var reg = /date/i;
    var reg = new RegExp('date','i');
    console.log(reg.test(s));

    console.log(s.search(reg))
</script>
</body>
</html>